#ifndef CONCRETEMAPINFO_H
#define CONCRETEMAPINFO_H

#include <QObject>
#include <unordered_map>
#include <functional>
#include <memory>
#include "tabframe/mapinfo/AbstractMapInfo/abstractmapinfotab.h"
#include "tabframe/mapinfo/ae/aeamp/aeampinfotab.h"
#include "tabframe/mapinfo/ae/aephase/aephaseinfotab.h"
#include "tabframe/mapinfo/ae/aepulse/aepulseinfotab.h"
#include "tabframe/mapinfo/ae/aewave/aewaveinfotab.h"
#include "tabframe/mapinfo/infrared/infraredinfotab.h"
#include "tabframe/mapinfo/prpd/prpdinfotab.h"
#include "tabframe/mapinfo/prps/prpsinfotab.h"
#include "tabframe/mapinfo/tev/tevamp/tevampinfotab.h"

/**
 * @brief 图谱工厂类
 * 使用注册式工厂模式，避免大量的switch-case语句
 */
class ConcreteMapInfo : public AbstractMapInfoTab
{
    Q_OBJECT
public:
    ConcreteMapInfo();
    ~ConcreteMapInfo() override = default;
    
    /**
     * @brief 创建图谱信息展示界面
     * @param spectrum 图谱数据
     * @return 创建的图谱信息展示界面，如果不支持该图谱类型则返回nullptr
     */
    MapInfoTab* createMapInfoTab(DataSpecificationGW::Spectrum* spectrum) override;
    
    /**
     * @brief 判断是否支持指定的图谱类型
     * @param spectrumTypeCode 图谱类型代码
     * @return 是否支持
     */
    bool supportsSpectrumType(uint8_t spectrumTypeCode) const override;
    
    /**
     * @brief 注册图谱创建器
     * @param spectrumTypeCode 图谱类型代码
     * @param creator 创建函数
     */
    template<typename T>
    void registerCreator(uint8_t spectrumTypeCode, std::function<T*(DataSpecificationGW::Spectrum*)> creator) {
        m_creators[spectrumTypeCode] = [creator](DataSpecificationGW::Spectrum* spectrum) -> MapInfoTab* {
            return creator(spectrum);
        };
    }
    
private:
    // 图谱创建器映射表
    std::unordered_map<uint8_t, std::function<MapInfoTab*(DataSpecificationGW::Spectrum*)>> m_creators;
};

#endif // CONCRETEMAPINFO_H
